// pages/xiangqing/xiangqing.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
      headimg:'/images/banner01.png',
      id:'',
      details:[],  //详情
      list:[
          {
        name:21,
        flag:true
      },{
        name:22,
        flag:true
      },{
        name:23,
        flag:true
      },
      {
        name:0,
        flag:true
      },{
        name:1,
        flag:true
      },{
        name:2,
        flag:true
      },
      {
        name:3,
        flag:false
      },{
        name:4,
        flag:false
      },{
        name:5,
        flag:true
      },
      {
        name:6,
        flag:true
      },{
        name:7,
        flag:true
      },{
        name:8,
        flag:true
      },  {
        name:9,
        flag:true
      },{
        name:10,
        flag:true
      },{
        name:11,
        flag:true
      },
      {
        name:12,
        flag:true
      },{
        name:13,
        flag:true
      },{
        name:14,
        flag:true
      },  {
        name:15,
        flag:true
      },{
        name:16,
        flag:true
      },{
        name:17,
        flag:true
      },
      {
        name:18,
        flag:true
      },{
        name:19,
        flag:true
      },{
        name:20,
        flag:true
      }
    ],
    // 可预约时间段和不可预约时间段

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {

    
    this.getLocation(e);

    // 定时获取店铺列表
    setInterval(()=>{
      this.getLocation(e);
    },5000)
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
    // 可预约时间段和不可预约时间段
    
// 下面不是预约时间段
  getLocation:function(e){
    var id = e.id;
    var stores = wx.getStorageSync('stores');
    // var arr=list.
    // stores.map(item => {
    //  item.zd_time==list.map
    // });
    this.data.list=stores
    stores.map(item=>{
        item.zd_time.map
    })
    if(stores.length > 0){
      var details = [];
      for (var i in stores) {
        if(id == stores[i].id){
          details.push({
            id: stores[i].id,
            address: stores[i].address,
            city_id: stores[i].city_id,
            close: stores[i].close,
            content: stores[i].content,
            distance: stores[i].distance,
            image: stores[i].image,
            label: stores[i].label,
            label_ids: stores[i].label_ids,
            lat: stores[i].lat,
            lon: stores[i].lon,
            min_price: stores[i].min_price,
            mobile: stores[i].mobile,
            name: stores[i].name,
            open: stores[i].open,
            rooms: stores[i].rooms,
          });
          
        }
      }

      this.setData({
        details:details
      })




    }else{
      // wx.removeStorageSync('stores');
      wx.showToast({
          title: '空空如也',
          icon: 'none'
      })
    }
  },
  callPhone:function(e){
    var tel = e.target.dataset.tel;
    if(tel)
        wx.makePhoneCall({
            phoneNumber: tel,
            success: function() {},
        })
  },
  listenerBtnGetLocation:function(e){
    console.log(e)
    var lat = e.currentTarget.dataset.lat;
    var tel = e.currentTarget.dataset.lon;
    var name = e.currentTarget.dataset.name;
    var address = e.currentTarget.dataset.address;
    console.log(lat)
    console.log(tel)
    wx.getLocation({
      //定位类型 wgs84, gcj02
      type: 'gcj02',
      success: function(res) {
        console.log(res)
        //return false
        wx.openLocation({
          //当前经纬度
          latitude: res.latitude,
          longitude: res.longitude,
          //缩放级别默认28
          scale: 28,
          //位置名
          name: name,
          //详细地址
          address: address,
          // //成功打印信息
          // success: function(res) {
          //   console.log(res)
          // },
          // //失败打印信息
          // fail: function(err) {
          //   console.log(err)
          // },
          // //完成打印信息
          // complete: function(info){
          //   console.log(info)
          // },
        })
 
      },
      fail: function(err) {
        console.log(err)
      },
      complete: function(info) {
        console.log(info)
      },
    })
    
  },
  reserve:function(e){
      console.log(e,'这是第5个')
    var id = e.target.dataset.id;
    if(id)
      wx.navigateTo({
        url: '/pages/book/book?id=' +id,
      })
  },







  
})